﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;

public partial class Account_Juego2_MembersOnly : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
    {
        Guid userid = (Guid)Membership.GetUser().ProviderUserKey;

         SqlConnection conn = new  SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
         SqlCommand cmd = conn.CreateCommand();
         SqlCommand cmd2 = conn.CreateCommand();
         conn.Open();
         cmd2.Parameters.Add("@userid", SqlDbType.UniqueIdentifier).Value = userid;
         cmd2.CommandText = "delete from Puntaje where (UserId=@userid and JuegoId=2)";
         SqlTransaction mytrans2 = conn.BeginTransaction();
         cmd2.Transaction = mytrans2;
         cmd2.ExecuteNonQuery();
         mytrans2.Commit();
          cmd.Parameters.Add("@userid", SqlDbType.UniqueIdentifier).Value = userid;
          cmd.CommandText = "insert into Puntaje (UserId,JuegoId,Puntaje) Values (@userid,2,2)";
          SqlTransaction mytrans = conn.BeginTransaction();
          cmd.Transaction = mytrans;
          cmd.ExecuteNonQuery();
          mytrans.Commit();
          conn.Close();
          Response.Redirect("~/Account/Juego3/Presentacion3.aspx");
    }
    protected void ImageButton6_Click(object sender, ImageClickEventArgs e)
    {
        Guid userid = (Guid)Membership.GetUser().ProviderUserKey;

        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
        SqlCommand cmd = conn.CreateCommand();
        SqlCommand cmd2 = conn.CreateCommand();
        conn.Open();
        cmd2.Parameters.Add("@userid", SqlDbType.UniqueIdentifier).Value = userid;
        cmd2.CommandText = "delete from Puntaje where (UserId=@userid and JuegoId=2)";
        SqlTransaction mytrans2 = conn.BeginTransaction();
        cmd2.Transaction = mytrans2;
        cmd2.ExecuteNonQuery();
        mytrans2.Commit();
        cmd.Parameters.Add("@userid", SqlDbType.UniqueIdentifier).Value = userid;
        cmd.CommandText = "insert into Puntaje (UserId,JuegoId,Puntaje) Values (@userid,2,5)";
        SqlTransaction mytrans = conn.BeginTransaction();
        cmd.Transaction = mytrans;
        cmd.ExecuteNonQuery();
        mytrans.Commit();
        conn.Close();
        Response.Redirect("~/Account/Juego3/Presentacion3.aspx");
    }
    protected void ImageButton7_Click(object sender, ImageClickEventArgs e)
    {
        Guid userid = (Guid)Membership.GetUser().ProviderUserKey;

        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
        SqlCommand cmd = conn.CreateCommand();
        SqlCommand cmd2 = conn.CreateCommand();
        conn.Open();
        cmd2.Parameters.Add("@userid", SqlDbType.UniqueIdentifier).Value = userid;
        cmd2.CommandText = "delete from Puntaje where (UserId=@userid and JuegoId=2)";
        SqlTransaction mytrans2 = conn.BeginTransaction();
        cmd2.Transaction = mytrans2;
        cmd2.ExecuteNonQuery();
        mytrans2.Commit();
        cmd.Parameters.Add("@userid", SqlDbType.UniqueIdentifier).Value = userid;
        cmd.CommandText = "insert into Puntaje (UserId,JuegoId,Puntaje) Values (@userid,2,3)";
        SqlTransaction mytrans = conn.BeginTransaction();
        cmd.Transaction = mytrans;
        cmd.ExecuteNonQuery();
        mytrans.Commit();
        conn.Close();
        Response.Redirect("~/Account/Juego3/Presentacion3.aspx");
    }
    protected void ImageButton8_Click(object sender, ImageClickEventArgs e)
    {
        Guid userid = (Guid)Membership.GetUser().ProviderUserKey;

        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
        SqlCommand cmd = conn.CreateCommand();
        SqlCommand cmd2 = conn.CreateCommand();
        conn.Open();
        cmd2.Parameters.Add("@userid", SqlDbType.UniqueIdentifier).Value = userid;
        cmd2.CommandText = "delete from Puntaje where (UserId=@userid and JuegoId=2)";
        SqlTransaction mytrans2 = conn.BeginTransaction();
        cmd2.Transaction = mytrans2;
        cmd2.ExecuteNonQuery();
        mytrans2.Commit();
        cmd.Parameters.Add("@userid", SqlDbType.UniqueIdentifier).Value = userid;
        cmd.CommandText = "insert into Puntaje (UserId,JuegoId,Puntaje) Values (@userid,2,7)";
        SqlTransaction mytrans = conn.BeginTransaction();
        cmd.Transaction = mytrans;
        cmd.ExecuteNonQuery();
        mytrans.Commit();
        conn.Close();
        Response.Redirect("~/Account/Juego3/Presentacion3.aspx");
    }
}